<template>
  <div class="footerInfo">
    <div>
      <img :src="songInfo.playImg" alt="" width="40" height="40" />
    </div>
    <div class="songInfo">
      <div>{{ songInfo.playSongName }} - {{ songInfo.playSinger }}</div>
      <div>
        {{ formatCurrentTime(props.currentTime) }} /
        {{ formatTotalTime(songInfo.totalTime) }}
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed, defineProps } from "vue";
import { useStore } from "vuex";
const store = useStore();
const props = defineProps({
  currentTime: {
    type: Number,
    default: 0,
  },
});
const songInfo = computed(() => store.getters.playInfo);
const formatTotalTime = computed(() => {
  return (time: number) => {
    const s = Math.floor(time / 1000);
    const m = Math.floor(s / 60);
    const second = s - m * 60;
    return `${m}:${second < 10 ? 0 + "" + second : second}`;
  };
});
const formatCurrentTime = computed(() => {
  return (time: number) => {
    const s = Math.floor(time);
    const m = Math.floor(s / 60);
    const second = s - m * 60;
    return `${m}:${second < 10 ? 0 + "" + second : second}`;
  };
});
</script>

<style lang="scss" scoped>
.footerInfo {
  display: flex;
  align-items: center;
  color: #bebebe;
  font-size: 14px;
  font-weight: bold;
  img {
    border-radius: 5px;
    margin-right: 8px;
  }
  .songInfo {
    div:nth-child(1) {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    div:nth-child(2) {
      color: #666;
      font-size: 13px;
      margin-top: 3px;
    }
  }
}
</style>
